﻿using Appliaction.Dto.Pinv;
using Appliaction.IAppServices.Pinv;
using Azure.Core.Serialization;
using Domain.Entitys.Pinv;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Storage.Json;

namespace API.Controllers.Pinv
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PuController : ControllerBase
    {
        private readonly IPuService puService;

        public PuController(IPuService puService)
        {
            this.puService = puService;
        }
        /// <summary>
        /// 分页条件查询信息
        /// </summary>
        /// <param name="Vendor_name"></param>
        /// <param name="Purret_code"></param>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public JsonResult GetPuFyWhereSelect(string? Vendor_name, string? Purret_code, int currentPage, int pageSize)
        {
            return new JsonResult(puService.GetPuFyWhereSelect(Vendor_name, Purret_code, currentPage, pageSize));
        }

        /// <summary>
        /// 条件查询总条数
        /// </summary>
        /// <param name="Vendor_name"></param>
        /// <param name="Purret_code"></param>
        /// <returns></returns>
        [HttpGet]
        public JsonResult GetPuWhereCount(string? Vendor_name, string? Purret_code)
        {
            return new JsonResult( puService.GetPuWhereCount(Vendor_name, Purret_code));
        }


        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="pinv_Purret"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<JsonResult> PutPuDelete(Pu_deleteDto pinv_Purret)
        {
            return new JsonResult(await puService.PutPuDelete(pinv_Purret));
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="Pu_Order_Details_AddDto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<JsonResult> PostPuAdd([FromBody] Pu_Order_Details_AddDto<Pu_AddDto> Pu_Order_Details_AddDto)
        {
            return new JsonResult(await puService.PostPuAdd(Pu_Order_Details_AddDto));
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="pu_Order_Details_UpdateDto"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<JsonResult> PutPuUpdate([FromBody] Pu_Order_Details_UpdateDto<Pu_UpdateDto> pu_Order_Details_UpdateDto)
        {
            return new JsonResult(await puService.PutPuUpdate(pu_Order_Details_UpdateDto));
        }

        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="pu_Order_Details_Dto"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<JsonResult> PutPuAudit(Pu_Order_details_Dto<Pu_Audit_Dto> pu_Order_Details_Dto)
        {
            return new JsonResult(await puService.PutPuAudit(pu_Order_Details_Dto));
        }
    }
}
